// pages/paySuccessful/paySuccessful.js
const app = getApp()
var api = require('../../../utils/api.js')
var util = require('../../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      oid: options.oid
    })
    this.doorInfo();
    this.orderInfo();
  },

//取货柜门
doorInfo:function(){
  var that = this;
  api.POST({
    params: { oid: that.data.oid },
    url: app.globalData.base_url + 'order/pickup',
    success: function (res) {
      if (util.isEmpty(res.data.code)) {
        var doorInfo = res.data.data;
        doorInfo = doorInfo.join('、')
        that.setData({
          doorInfo: doorInfo
        })
      } else {
        util.showError(res.data.message);
      }
    },
    fail: function (fail) {
      util.showError("网络错误");
    }
  })
},

  // 订单信息
  orderInfo: function () {
    var that = this;
    api.POST({
      params: { oid: that.data.oid },
      url: app.globalData.base_url + 'couponsorder/info',
      success: function (res) {
        if (util.isEmpty(res.data.code)) {
          that.setData({
            orderInfo: res.data.data,
            items: res.data.data.productList
          })
        } else {
          util.showError(res.data.message);
        }
      },
      fail: function (fail) {
        util.showError("网络错误");
      }
    })
  },

  complete: function () {
    wx.switchTab({
      url: '/pages/index/index'
    })
  }
})